<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :dictMap="dictMapAsync"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
    ></Ht-search-form>

    <!--    <div class="page-label-block">-->
    <!--      <span class="color-block">|</span>-->
    <!--      <span class="page-label-name">-->
    <!--      租户管理-->
    <!--      </span>-->
    <!--    </div>-->

    <ht-table
      ref="dataTable"
      :multi-select="false"
      :showSerialNumber="false"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      :reqConfig="regConfig"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="50" fixed="right">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog :title="title"  center :visible.sync="open" width="1024px" append-to-body :close-on-click-modal="false">
      <el-form ref="detailForm" :model="detailForm" :rules="rules" label-width="120px" :disabled="true">
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>基本信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="id">
                <el-input v-model="detailForm.id" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="报文标识号" prop="pkgId">
                <el-input v-model="detailForm.pkgId" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="CPG日期" prop="workdate">
                <el-date-picker v-model="detailForm.workdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="查询调整标识" prop="protoInqRef">
                <el-select style="width: 100%" v-model="detailForm.protoInqRef" placeholder="查询调整标识">
                  <el-option
                    v-for="dict in dictMap.PROTO_INQ_REF"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发起行行号" prop="indirectSender">
                <el-input v-model="detailForm.indirectSender" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="发起行行名" prop="indirectSendername">
                <el-input v-model="detailForm.indirectSendername" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="接收行行号" prop="indirectRecver">
                <el-input v-model="detailForm.indirectRecver" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="接收行行名" prop="indirectRecvername">
                <el-input v-model="detailForm.indirectRecvername" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>申请信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="协议号" prop="proto">
                <el-input v-model="detailForm.proto" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="协议类型" prop="protoType">
                <el-select style="width: 100%" v-model="detailForm.protoType" placeholder="协议类型">
                  <el-option
                    v-for="dict in dictMap.PROTOCOL_TYPE"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="变更类型" prop="chgType">
                <el-select style="width: 100%" v-model="detailForm.chgType" placeholder="变更类型">
                  <el-option
                    v-for="dict in dictMap.CHANGECODE392"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="付款人账号" prop="payerActno">
                <el-input v-model="detailForm.payerActno" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="付款人名称" prop="payerName">
                <el-input v-model="detailForm.payerName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="付款行行号" prop="payerBrno">
                <el-input v-model="detailForm.payerBrno" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="付款行行名" prop="payerBrName">
                <el-input v-model="detailForm.payerBrName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="付款人清算行行号" prop="payerStBrno">
                <el-input v-model="detailForm.payerStBrno" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="付款人清算行行名" prop="payerStBrnoname">
                <el-input v-model="detailForm.payerStBrnoname" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="付款人开户行行号" prop="payerAccBrno">
                <el-input v-model="detailForm.payerAccBrno" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="付款人开户行行名" prop="payerAccBrName">
                <el-input v-model="detailForm.payerAccBrName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="收款人名称" prop="payeeName">
                <el-input v-model="detailForm.payeeName" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="状态" prop="status">
                <el-select style="width: 100%" v-model="detailForm.status" placeholder="状态">
                  <el-option
                    v-for="dict in dictMap.PKG_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="录入操作员" prop="mdTlrno">
                <el-input v-model="detailForm.mdTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="录入时间" prop="mdTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.mdTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发送时间" prop="sndTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.sndTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="form-card txnInfo-card" v-if="this.show393">
          <div slot="header" class="label-header-msg">
            <span>应答信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="协议号" prop="proto">
                <el-input v-model="detailForm393.proto" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="付款人账号" prop="payerActno">
                <el-input v-model="detailForm393.payerActno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="付款人名称" prop="payerName">
                <el-input v-model="detailForm393.payerName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="付款人开户行行号" prop="payerAccBrno">
                <el-input v-model="detailForm393.payerAccBrno" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="付款人开户行行名" prop="payerAccBrName">
                <el-input v-model="detailForm393.payerAccBrName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="收款人名称" prop="payeeName">
                <el-input v-model="detailForm393.payeeName" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="付款人账户状态" prop="payerAccStatus">
                <el-select style="width: 100%" v-model="detailForm393.payerAccStatus" placeholder="付款人账户状态">
                  <el-option
                    v-for="dict in dictMap.ACCT_STATUS_312"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="接收时间" prop="rcvTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm393.rcvTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="业务状态" prop="bizStatus">
                <el-select style="width: 100%" v-model="detailForm393.bizStatus" placeholder="业务状态">
                  <el-option
                    v-for="dict in dictMap.CHECK_PROC_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="业务拒绝处理码" prop="bizRejectCode">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm393.bizRejectCode === null || detailForm393.bizRejectCode === undefined
                      ? ''
                      : detailForm393.bizRejectCode + '-' + detailForm393.bizRejectCodeDesc
                  "
                  placeholder="业务拒绝处理码"
                ></el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="业务拒绝信息" prop="bizRejectInfo">
                <el-input type="textarea" v-model="detailForm393.bizRejectInfo" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPageMixin } from "@/libs/listPageMixin";
import { AgentPayInOutPtlMgtNotiQueryDetail, apiUrlConfigPtlMgtNotiQuery } from "@/api/cnaps/beps/392";
export default {
  name: "AgentPayInOutPtlMgtNotiQuery",
  mixins: [listPageMixin],
  components: {},
  data() {
    return {
      // 查询参数
      queryParams: {
        proto:'',
        protoInqRef:'',
        startWorkdate:'',
        endWorkdate:'',
        chgType:'',
      },
      loading: false,
      // 搜索
      formOptions: [],
      //
      searchFormDictList: [
        "PROTO_INQ_REF",
        "CHANGECODE392",
        "PROTOCOL_TYPE",
        "PKG_STATUS",
        "ACCT_STATUS_312",
        "CHECK_PROC_STATUS",
      ],
      // 列信息
      regConfig: apiUrlConfigPtlMgtNotiQuery,
      tableBindColumns: [
        { prop: "id", label: "交易流水号", width: 180 },
        { prop: "workdate", label: "工作日期", type: "date", width: 120 },
        { prop: "proto", label: "协议号", width: 120 },
        { prop: "protoInqRef", label: "查询调整标识", dictCode: "PROTO_INQ_REF", width: 120 },
        { prop: "chgType", label: "变更类型", dictCode: "CHANGECODE392", width: 120 },
        { prop: "payerActno", label: "付款人账号", width: 180 },
        { prop: "payerName", label: "付款人名称", width: 120 },
        { prop: "payeeName", label: "收款人名称"},
      ],
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      detailForm: {},

      detailForm393: {},

      show393: false,

      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "proto",
        defaultAttr: {
          size: "small",
          label: "协议号",
          placeholder: "请输入协议号",
        },
      },

      {
        type: "dict",
        dict: "PROTO_INQ_REF",
        prop: "protoInqRef",
        defaultAttr: {
          size: "small",
          label: "查询调整标识",
          placeholder: "请输入查询调整标识",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "startWorkdate",
          endTimeName: "endWorkdate",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dict",
        dict: "CHANGECODE392",
        prop: "chgType",
        defaultAttr: {
          size: "small",
          label: "变更类型",
          placeholder: "请输入变更类型",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "代收付协议管理通知查询明细";
      AgentPayInOutPtlMgtNotiQueryDetail(row).then((response) => {
        this.detailForm = response.result.data;
        this.show393 = response.result.show393;
        if (this.show393) {
          this.detailForm393 = response.result.data393;
        }
        this.open = true;
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
